package thread;

public class demo8 {
    private static long result = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            for (long i = 0; i < 500000000; i++) {
                result ++;
            }
            System.out.println("t线程执行完毕");
        });
        t.start();
        //t.join();//死等
//        Thread.sleep(2);
        t.join(200);//带有超时时间的等待
        System.out.println(result);
        System.out.println(t.getState());//线程执行完毕,即刻在操作系统将线程销毁,但是Thread对象还在,所以线程状态为TERMINATED
    }


}
